﻿cmake_minimum_required(VERSION 2.8)
project(osg3rd)
option(BUILD_APPS "Build related apps")
option(BUILD_STATIC "Build static library")

macro(clear_vars)
  foreach(_var ${ARGN})
    unset(${_var})
    unset(${_var} CACHE)
  endforeach()
endmacro()

macro(add_subdir)
  foreach(_var ${ARGN})
    string(TOUPPER ${_var} varU)
	clear_vars(${varU}_LIBRARY ${varU}_LIBRARIES ${varU}_INCLUDE_DIR)
	set(${varU}_LIBRARY ${_var} CACHE INTERNAL "")
	add_subdirectory(${_var})
	set(${varU}_INCLUDE_DIR "${${${varU}_LIBRARY}_SOURCE_DIR}" "${${${varU}_LIBRARY}_BINARY_DIR}" CACHE INTERNAL "")
	set(${varU}_INCLUDE_DIRS ${${varU}_INCLUDE_DIR})
	set(${varU}_LIBRARIES ${${varU}_LIBRARY})
	set(${varU}_SOURCE_DIR "${${${varU}_LIBRARY}_SOURCE_DIR}")
	set(${varU}_FOUND TRUE)
  endforeach()
endmacro()

add_subdir(zlib liblzma libbz2 jpeg libpng libgif libtiff sqlite3 geos glut proj freetype openssl libssh2 libcurl expat iconv libxml2 gdal fftss exiv2 libprotobuf log4cpp FFmpeg)
